package test.server;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * TODO
 * Created by jinju on 2016/10/25.
 */
public class HelloServerHandler extends SimpleChannelInboundHandler<String>{

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        super.channelRead(ctx, msg);

    }

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
        System.out.println(this.getClass() + ".channelRead0");
        System.out.println(msg);
        ctx.writeAndFlush("Received your message!");
    }

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        System.out.println(this.getClass() + ".channelActive");

        ctx.writeAndFlush("Welcome !");
        super.channelActive(ctx);
    }
}
